package com.tfjybj.itoo.teach.provider.service.impl;

import com.dmsdbj.itoo.tool.base.service.impl.BaseServicePlusImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tfjybj.itoo.teach.entity.RoomTimeEntity;
import com.tfjybj.itoo.teach.model.RoomTimeModel;
import com.tfjybj.itoo.teach.provider.dao.RoomTimeDao;
import com.tfjybj.itoo.teach.provider.service.RoomTimeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * RoomTimeService接口实现类
 * ${base}表
 *
 * @author 田成荣
 * @version 2.0.0
 * @since 2.0.0 2018-11-08 19:34:10
 */
@Service("roomTimeService")
public class RoomTimeServiceImpl extends BaseServicePlusImpl<RoomTimeDao, RoomTimeEntity> implements RoomTimeService {
	
	//region 模板生成
    @Resource
    private RoomTimeDao roomTimeDao;

	 @Override
    public PageInfo<RoomTimeEntity> queryByLikeRoomId(String roomId, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return new PageInfo<>(roomTimeDao.queryLikeRoomId(roomId));
    }

    //endregion

    /* **********************************以下为非模板生成的内容********************************* */


    /**
     * 根据教室id查询该教室星期节次占用情况
     * @param roomId
     * @return 已经占用的时间点(星期和节次列表)
     * @author 杨晓慧
     * @since 2.0.0 2018-11-09 19:34:10
     */
    @Override
    public List<RoomTimeModel> queryRoomUseByRoomId(String roomId) {

        return roomTimeDao.queryRoomUseByRoomId(roomId);

    }


    /**
     * 根据教师id 和当前星期节次信息判定教师在当前时间段内有没有其他课：
     * @param teacherId  教师id
     * @param week  周次（星期XX）
     * @param cellTimeId 节次 （第几节课）
     * @return 返回老师在此时间点上了几节课
     * @author 杨晓慧
     * @since 2.0.0 2018-11-09 19:34:10
     */
    @Override
    public int queryTeacherUseByTime(String teacherId, String week, String cellTimeId) {
       return roomTimeDao.queryTeacherUseByTime(teacherId,week,cellTimeId);
    }

    /**
     *查询上课班在既定星期节次内有没有上课
     * @param teachClassId
     * @param week
     * @param cellTimeId
     * @return
     */
    @Override
    public List<RoomTimeModel> queryTeachClassUseByTime(String teachClassId, String week, String cellTimeId) {
        return roomTimeDao.queryTeachClassUseByTime(teachClassId, week, cellTimeId);
    }
}
